package com.jinlong.controller;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jinlong.annotation.MyAutowired;
import com.jinlong.annotation.MyController;
import com.jinlong.annotation.MyRequestMapping;
import com.jinlong.annotation.MyRequestParam;
import com.jinlong.service.MainService;

import java.io.IOException;
import java.io.PrintWriter;

@MyController
@MyRequestMapping("/jinlong")
public class MainController {
    @MyAutowired("MainServiceImpl")
    private MainService mainService;

    @MyRequestMapping("/query")
    public void query(HttpServletRequest request, HttpServletResponse response,
                      @MyRequestParam("name")String name,
                      @MyRequestParam("age")String age){
        try {
            PrintWriter printWriter = response.getWriter();
            String query = mainService.query(name,age);
            printWriter.write(query);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
